//
//  AXFCouponCell.m
//  BEEQUICK
//
//  Created by admin on 20/11/2016.
//  Copyright © 2016 SevenGroup. All rights reserved.
//

#import "AXFCouponCell.h"

@implementation AXFCouponCell

- (void)awakeFromNib {
	[super awakeFromNib];
	// Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
	[super setSelected:selected animated:animated];
	
	// Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
	if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
		[self setupUI];
	}
	return self;
}

- (void)setupUI {
	UITextField *inputTextField = [[UITextField alloc] init];
	UIButton *bindingBtn = [self setupBtnWithText:@"绑定"];
	
	inputTextField.placeholder = @"请输入优惠券号码";
	inputTextField.font = [UIFont systemFontOfSize:14];
	
	[self.contentView addSubview:inputTextField];
	[self.contentView addSubview:bindingBtn];
	
	[bindingBtn mas_makeConstraints:^(MASConstraintMaker *make) {
		make.centerY.equalTo(self.contentView);
		make.width.equalTo(@75);
		make.right.offset(-15);
	}];
	
	[inputTextField mas_makeConstraints:^(MASConstraintMaker *make) {
		make.centerY.equalTo(bindingBtn);
		make.left.offset(15);
		make.right.equalTo(bindingBtn.mas_left).offset(-15);
	}];
}

- (UIButton *)setupBtnWithText:(NSString *)text {
	UIButton *btn = [UIButton cz_textButton:text fontSize:14 normalColor:UIColor.blackColor selectedColor:[UIColor cz_colorWithHex:0xd3c8b3]];
	
	[btn setBackgroundImage:[UIImage imageNamed:@"v2_coupon_verify_normal"] forState:UIControlStateNormal];
	[btn setBackgroundImage:[UIImage imageNamed:@"v2_coupon_verify_selected"] forState:UIControlStateHighlighted];
	
	[self.contentView addSubview:btn];
	[btn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
	return btn;
}

- (void)btnAction:(UIButton *)btn {
	NSLog(@"绑定了!!!!");
}

@end

